{layout name="public/layout" /}
{include file='yxnavbar'}
<link href="{$_G['URL']['LAYER_CSS']}/layui.css" rel="stylesheet" xmlns="http://www.w3.org/1999/html">

<div class="main">
    <ul class="nav nav-tabs">
        <li ><a href="{php echo createWebUrl('shangjia');}">可用商家列表</a></li>
        <li ><a href="{php echo createWebUrl('shangjia', array('action' =>2));}">暂停商家列表</a></li>
        <li {if $action == 3}class="active"{/if}><a href="{php echo createWebUrl('shangjia', array('action' =>3));}">商家报名信息</a></li>
        <li ><a href="{php echo createWebUrl('shangjiaadd');}">新增商家</a></li>
        <li {if $action == 4}class="active"{/if}><a href="{php echo createWebUrl('shangjia', array('action' =>4));}">分组管理</a></li>
        <li ><a href="{php echo createWebUrlPlugin('sjmulitverify.index',array('themeid'=>$themeid));}">商家产品列表</a></li>
        <li {if $action=='user'}class="active"{/if}><a href="{php echo createWebUrlPlugin('sjmulitverify.index.user',array('themeid'=>$themeid));}">商家产品-用户记录</a></li>
    </ul>
    <div class="panel panel-info">
        <div class="panel-heading">当前数量： {$total}</div>
        <div class="panel-body">
            <form id = "myform" action="./index.php" method="get" class="form-horizontal" role="form">
                <input type="hidden" name="c" value="site" />
                <input type="hidden" name="a" value="entry" />
                <input type="hidden" name="m" value="{$_P['m']}" />
                <input type="hidden" name="do" value="web" />
                <input type="hidden" name="r" value="sjmulitverify.index.user" />
                <div class="form-group clearfix">
                    {if !$order_id}
                    <div class="form-group">
                        <label class="col-xs-1 col-sm-1 col-md-1 control-label">商家</label>
                        <div class="col-xs-11 col-sm-9 col-md-9">
                            <div class="btn-group">
                                {loop $list_arr $row}
                                <a href="{php echo createWebUrlPlugin('sjmulitverify.index.user',['sj_id'=>$row['id']]);}" class="btn {if $sj_id == $row['id']}btn-primary{else}btn-default{/if}">
                                    {$row['title']}
                                    <span style="color: #ff0000">{$row['total']}</span>
                                </a>
                                {/loop}
                            </div>

                        </div>
                    </div>
                    {/if}
                    <div class="form-group">
                        <label class="col-xs-1 col-sm-1 col-md-1 control-label">状态</label>
                        <div class="col-xs-11 col-sm-9 col-md-9">
                            <div class="btn-group">
                                {loop $status_arr $row}
                                <a href="{php echo createWebUrlPlugin('sjmulitverify.index.user',['status'=>$row['status'],'sj_id'=>$sj_id,'order_id'=>$order_id]);}" class="btn {if $status == $row['status']}btn-primary{else}btn-default{/if}">
                                    {$row['title']}
                                    <span style="color: #ff0000">{$row['total']}</span>
                                </a>
                                {/loop}
                            </div>

                        </div>
                    </div>
                    <label class="col-xs-12 col-sm-3 col-md-1 control-label">搜索条件</label>
                    <div class="col-sm-3 col-xs-3 col-md-3">
                        <input class="form-control" name="search_data" placeholder="输入产品名称、姓名、电话、微信昵称" type="text" value="{$_P['search_data']}">
                    </div>
                    <div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
                        <button class="btn btn-primary"><i class="fa fa-search"></i> 搜索</button>
                        <input type="hidden" name="__token__" value="{$Request.token}"/>
                    </div>
                    <div class="col-sm-1 col-lg-1 col-md-1 col-xs-2">
                        <div class="btn-group">
                            <input type="hidden" name="status" value="{$status}">
                            <input type="hidden" name="sj_id" value="{$sj_id}">
                            <input type="hidden" name="order_id" value="{$order_id}">
                            <input class="btn btn-default" type="submit" name="export_submit" onclick="jump()" id="export_submit" value="导出EXCEL">
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<div class="panel panel-default">
    <div class="panel-body table-responsive">
        <table class="table table-hover">
            <thead class="navbar-inner">
            <tr>
                <th style="width:50px;">序号</th>
                <th style="width:100px;">昵称</th>
                <th style="width:100px;">姓名/电话</th>
                <th style="width:80px;">定单号</th>
                <th style="width:60px;">下单时间</th>
                <th style="width:120px;">商家</th>
                <th style="width:120px;">产品</th>
                <th style="width:120px;">核销状态</th>
                <th style="width:120px;">核销时间</th>
                <th style="width:120px;">核销人</th>
                <th style="width:120px;">核销人电话</th>
            </tr>
            </thead>
            <tbody>
            {loop $list $i $item}
            <tr>
                <td>{php echo $i+1;}</td>
                <td>
                    <img src="{php echo tomedia($item['avatar']);}" width="28" style="border-radius: 3px;"><br>
                    {$item['nickname']}
                </td>
                <td>{$item['username']}<br>{$item['mobile']}</td>

                <td><a><span class="label label-success">{php echo (9000+$item['order_id']);}</span></a></td>
                <td>{$item['order_time']}</td>
                <td>{$item['shangjia_name']}</td>
                <td>{$item['name']}</td>
                <td>
                    {if $item['status']==1}
                    <span class="label label-success">待核销</span>
                    {elseif $item['status']==2}
                    <span class="label label-danger">已核销</span>
                    {else}
                    {/if}
                </td>
                <td>
                    {if $item['updated_at'] && $item['status']==2}{php echo $item['updated_at'];}{/if}
                </td>
                <td>
                    {if $item['status']==2}
                        {if $item['companyname']}{php echo $item['companyname'];}<br>{/if}
                        {if $item['teamname']}{php echo $item['teamname'];}<br>{/if}
                        {if $item['workername']}{php echo $item['workername'];}<br>{/if}
                    {/if}
                </td>
                <td>
                    {if $item['workermobile']}{php echo $item['workermobile'];}{/if}
                </td>
            </tr>
            {/loop}
            </tbody>
        </table>
    </div>
</div>
{$pager}
<script type="text/javascript">
    function jump(){
        layer.msg('正在准备下载');
    }
    function uploadFile(){
        var formData = new FormData($( "#uploadForm" )[0]);
        postUrl = "{php echo createWebUrlPlugin('sjmulitverify.index.uploadFile',array('themeid'=>$themeid));}";
        layer.msg('您确定导入电子表格中的全部记录吗？',{
            btn:['确定','取消'],
            yes:function (index) {
                $.ajax({
                    url:postUrl,
                    dataType:'json',
                    method:'post',
                    data: formData,
                    processData: false,
                    contentType: false,
                    success:function (e) {
                        let res = e.message;
                        let code = res.code;
                        let msg = res.msg;
                        if (code!=200){
                            layer.msg(msg);
                        }else{
                            layer.msg(msg);
                            location.reload();
                        }
                    },
                    fail:function (err) {
                        console.log(err)
                    }
                });
            }
        });

    }
    function editStatus(e) {
        let id = e.getAttribute("data-id");
        let type = e.getAttribute("data-type");
        let value = '';
        editItem(type,value,id)
    }
    function editItem(type,value,id)
    {
        var postUrl = "{php echo createWebUrlPlugin('sjmulitverify.index.editItem', array('themeid'=>$themeid));}";
        $.ajax({
            url:postUrl,
            dataType:'json',
            method:'post',
            data: {id:id,type:type,val:value},
            success:function (e) {
                let res = e.result;
                let status = res.status;
                let msg = res.msg;
                if (status!=1){
                    layer.msg(msg);
                }else{
                    layer.msg(msg);
                }
                window.location.reload();
            },
            fail:function (err) {
                console.log(err)
            }
        });
    }
    function optAll(type) {
        let tmp_tip = '确认当前操作吗？';
        if (type=='out'){
            tmp_tip = '确认上架所有产品吗？';
        }else if (type=='in'){
            tmp_tip = '确认下架所有产品吗？';
        }else if (type=='del'){
            tmp_tip = '确认删除所有产品吗？';
        }
        layer.confirm(tmp_tip,
            {btn:['确认','取消']},
            function () {
                var postUrl = "{php echo createWebUrlPlugin('sjmulitverify.index.opType', array('themeid'=>$themeid));}";
                $.ajax({
                    url:postUrl,
                    dataType:'json',
                    method:'post',
                    data: {type:type},
                    success:function (e) {
                        let res = e.result;
                        let status = res.status;
                        let msg = res.msg;
                        if (status!=1){
                            layer.msg(msg);
                        }else{
                            layer.msg(msg);
                        }
                        window.location.reload();
                    },
                    fail:function (err) {
                        console.log(err)
                    }
                });
            },
            function () {
                layer.msg('已取消',{icon:2});
            }
        );

    }
</script>
